home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 16 code / CollaboDraw / trapavailable.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-24  |  1.6 KB  |  78 lines  |  [TEXT/MPS ]

  1. /*-------------------------------------------------------------------------------------
  2.  *
  3.  * Simple Sample PowerTalk Application Framework
  4.  *
  5.  * ©1991-1993 Apple Computer
  6.  *
  7.  -------------------------------------------------------------------------------------*/
  8. /*
  9.  * trapavailable.c -- checks to see if a trap is implemented
  10.  *
  11.  * change history:
  12.  *
  13.  * SJF        08/23/93        1.0f1        update to final headers, fix comments
  14.  * SJF        04/21/93        1.0b2        update to b2
  15.  * SJF        03/01/93        1.0b1        added digital signatures
  16.  * SJF        02/09/93        1.0b1        update to b1
  17.  * SJF        10/13/92        1.0d4        update to a11
  18.  * SJF        09/09/92        1.0d3        update to a9
  19.  * SJF        05/07/92        1.0d2        update to a6
  20.  * SJF        11/06/91        1.0d1        initial coding
  21.  *
  22.  */
  23.  
  24. #pragma segment othersegment
  25.  
  26. #ifndef __TYPES__
  27. #include <Types.h>
  28. #endif
  29.  
  30. #ifndef __TRAPS__
  31. #include <Traps.h>
  32. #endif
  33.  
  34. #ifndef __OSUTILS__
  35. #include <OSUtils.h>
  36. #endif
  37.  
  38. #ifndef __GESTALTEQU__
  39. #include <GestaltEqu.h>
  40. #endif
  41.  
  42. #include "trapavailable.h"
  43.  
  44. short NumToolboxTraps(void);
  45. TrapType GetTrapType(short theTrap);
  46.     
  47. short NumToolboxTraps(void)
  48. {
  49.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  50.         return 0x0200;
  51.     else
  52.         return 0x0400;
  53. }
  54.  
  55. TrapType GetTrapType(short theTrap)
  56. {
  57.     if ((theTrap & 0x0800) > 0)
  58.         return ToolTrap;
  59.     else
  60.         return OSTrap;
  61. }
  62.  
  63. Boolean    TrapAvailable(short theTrap)
  64. {
  65.     TrapType tType;
  66.     Boolean isAvail;
  67.     
  68.     tType = GetTrapType(theTrap);
  69.     if (tType == ToolTrap)
  70.         {
  71.             theTrap &= 0x07FF;
  72.             if (theTrap >= NumToolboxTraps())
  73.                 theTrap = _Unimplemented;
  74.         }
  75.     
  76.     isAvail = NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
  77.     return isAvail;
  78. }